package Practice08.test1;

import java.util.ArrayList;
import java.util.List;

public class TestStudent {
    public static void main(String[] args) {

        int sumScore = 0;
        int num = 0;
        double ave;

        List<Student> students = new ArrayList<>();
        students.add(new Student("zhangsan","class1","java",85));
        students.add(new Student("lisi","class1","C#",79));
        students.add(new Student("wangwu","class2","C#",52));
        students.add(new Student("zhaoliu","class2","java",49));

        for (Student s: students) {
            System.out.println(s);
            if (s.getClassName().equals("class1")){

                sumScore += s.getScore();
                num++;
            }
        }
        ave = sumScore / num;
        System.out.println("class1的总分："+sumScore+"    "+"class1的平均分："+ave);
        num = 0;
        sumScore = 0;

        for (Student s: students) {
            if (s.getLesson().equals("java")){

                sumScore += s.getScore();
                num++;
            }
        }
        ave = sumScore / num;
        System.out.println("java的总分："+sumScore+"    "+"java的平均分："+ave);
        num = 0;
        sumScore = 0;

        for (Student s: students) {
            if (s.getLesson().equals("C#")){

                sumScore += s.getScore();
                num++;
            }
        }
        ave = sumScore / num;
        System.out.println("C#的总分："+sumScore+"    "+"C#的平均分："+ave);
    }
}
